package com.ml.mall.api.comparison;

import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.req.comparison.SysComparisonAddDto;
import com.ml.mall.bean.req.comparison.SysComparisonDelDto;
import com.ml.mall.bean.res.comparison.SysComparisonRes;
import com.ml.mall.consts.PermissionConst;
import com.ml.mall.service.comparison.SysComparisonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author :pl
 * @version :1.0
 * @description :对比Redis接口
 * @date :2021/5/28
 **/
@RestController
@Api(tags = "【shopping】Redis比对接口")
@RequestMapping("/product")
public class SysComparisonController {

    @Autowired
    private SysComparisonService sysComparisonService;



    @ApiOperation(value = "信息比对添加实现接口")
    @PostMapping(value = "/shop_comparison_add")
//    @RequiresPermissions(PermissionConst.PRODUCT_SHOP_COMPARISON_ADD)
    public ApiRestResult comparisonAdd(@RequestBody @Valid SysComparisonAddDto dto){
        sysComparisonService.sysComparisonAdd(dto);
        return ApiRestResult.ok();
    }


    @ApiOperation(value = "根据companyId进行redis信息查询")
    @PostMapping(value = "/shop_comparison_query")
//    @RequiresPermissions(PermissionConst.PRODUCT_SHOP_COMPARISON_QUERY)
    public ApiRestResult comparisonQuery(){
        return ApiRestResult.ok(sysComparisonService.sysComparisonQuery());
    }

    @ApiOperation(value = "删除一条redis中存储数据")
    @PostMapping(value = "/shop_comparison_del")
//    @RequiresPermissions(PermissionConst.PRODUCT_SHOP_COMPARISON_DEL)
    public ApiRestResult comparisonDel(@RequestBody SysComparisonDelDto dto){
        sysComparisonService.sysComparisonDel(dto);
        return ApiRestResult.ok();
    }
}
